from std_msgs.msg import String
from rclpy.node import Node
import datetime


class SimpleTopicSub(Node):
    def __init__(self, name: str):
        super().__init__(name)
        self.sub = self.create_subscription(String, "simple_topic_message", self.callback, 10)

    def callback(self, message: String):
        current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]  # 精确到毫秒
        self.get_logger().info(f'当前时间: {current_time}, 接受到数据: {message.data}')
